package com.app.command;

import java.io.BufferedReader;

import com.app.dao.BookDAO;
import com.app.dao.entity.Book;

public class FindBookByTitle extends Command {
//not begin trnsaktion
	@Override
	protected CommandResult execute(BufferedReader dataLineReader)
			throws Exception {
		CommandResult result = new CommandResult(CommandResultStatus.SUCCESSFUL);
		BookDAO bookDAO = new BookDAO();

		System.out.print(" Enter BookTitle ");
		String bookTitle = dataLineReader.readLine();
		Book book = bookDAO.findBook(bookTitle);

		if (book != null) {
			System.out.println("Find Book-----ОК\t\n" + book);
		} else {
			System.out.println("Book " + bookTitle + " not find");
		}
		return result;

	}
}